package com.mstar.qs.common.thread;

import java.util.HashMap;
import java.util.Map;

public class ThreadLocalFactory {
	private static final ThreadLocal<Map<String, Object>> tl = new ThreadLocal<Map<String, Object>>();
	private static final ThreadLocal v = new ThreadLocal();

	public static Object get(String key) {
		Map<String, Object> o = tl.get();
		if (o == null)
			return null;
		return o.get(key);
	}

	public static void set(String key, Object v) {
		Map<String, Object> o = tl.get();
		if (o == null) {
			o = new HashMap<String, Object>();
			tl.set(o);
		}
		o.put(key, v);
	}
	
	public static Object get() {
		return v.get();
	}
	public static void set(Object o) {
		v.set(o);
	}

}
